//
//  BorderButton.m
//  MoneyIndividual
//
//  Created by Le Anh Tai on 1/11/14.
//  Copyright (c) 2014 Le Anh Tai. All rights reserved.
//

#import "BorderButton.h"

@implementation BorderButton

- (id)initWithTitle:(NSString *)title
{
    self = [super init];
    
    if (self)
    {
        [self setTitle:title forState:UIControlStateNormal];
        
        [self initialize];
    }
    
    return self;
}

- (id)init
{
    self = [super init];
    if (self)
    {
        [self initialize];
    }
    
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self)
    {
        [self initialize];
    }
    
    return self;
}

- (void)initialize
{
    _borderColor = [UIColor whiteColor];
    
//    [self setBackgroundColor:COLOR_GREEN_NORMAL];
    [self setBackgroundColor:[UIColor darkGrayColor]];
    
    self.layer.borderColor = _borderColor.CGColor;
    self.layer.borderWidth = 0;
    
}

- (void)setFrame:(CGRect)frame
{
    [super setFrame:frame];
    
    self.layer.cornerRadius = self.width/2;
}

- (void)setBorderColor:(UIColor *)borderColor
{
    _borderColor = borderColor;
    self.layer.borderColor = _borderColor.CGColor;
}

- (void)setHighlighted:(BOOL)highlighted
{
    [super setHighlighted:highlighted];
    
    if (highlighted)
    {
//        self.layer.backgroundColor = COLOR_DARK_GREEN.CGColor;
        self.layer.backgroundColor = [UIColor lightGrayColor].CGColor;
    }
    else
    {
//        self.layer.backgroundColor = COLOR_GREEN_NORMAL.CGColor;
        self.layer.backgroundColor = [UIColor darkGrayColor].CGColor;
    }
}
@end
